﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using RunAllTestsInSolutionTask;

namespace RunAllTestsInSolutionTaskTests
{
    [TestFixture]
    class ProjectParserTests
    {
        [Test]
        public void IsTestProject_GivenNoneExistantFile_ThrowsException()
        {
            Assert.Throws<ArgumentException>(() =>
                ProjectParser.IsTestProject("NoSuchFile.vcproj"));
        }

        [Test]
        public void IsTestProject_OnNoneXmlFile_ThrowsException()
        {
            Assert.Throws<ArgumentException>(() =>
                ProjectParser.IsTestProject("BadFormat.vcproj"));
        }

        [Test]
        public void IsTestProject_GivenMsTestProject_ReturnsTrue()
        {
            var actual = ProjectParser.IsTestProject(@"TestData\CTesting.AddinTests.csproj");
            Assert.IsTrue(actual);
        }

        [Test]
        public void IsTestProject_NotTestProject_ReturnsFalse()
        {
            var actual = ProjectParser.IsTestProject(@"TestData\RunAllTestsInSolution.csproj");
            Assert.IsFalse(actual);
        }

        [Test]
        public void GetProjectDll_ForDebug_ReturnsDebugDllName()
        {
            var dllName = ProjectParser.GetOutputDll(@"TestData\RunAllTestsInSolution.csproj", "Debug");
            Assert.AreEqual(@"TestData\bin\Debug\RunAllTestsInSolution.dll", dllName);
        }

        [Test]
        public void GetProjectDll_ForRelease_ReturnsReleaseDllName()
        {
            var dllName = ProjectParser.GetOutputDll(@"TestData\RunAllTestsInSolution.csproj", "Release");
            Assert.AreEqual(@"TestData\bin\Release\RunAllTestsInSolution.dll", dllName);
            
        }

        [Test]
        public void GetProjectDll_GivenNoneExistantFile_ThrowsException()
        {
            Assert.Throws<ArgumentException>(() =>
                ProjectParser.IsTestProject("NoSuchFile.vcproj"));
        }

        [Test]
        public void GetProjectDll_OnNoneXmlFile_ThrowsException()
        {
            Assert.Throws<ArgumentException>(() =>
                ProjectParser.IsTestProject("BadFormat.vcproj"));
        }

    }
}
